package com.tancire.net.service.impl;

import java.util.List;
import javax.annotation.Resource;
import com.tancire.common.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.tancire.net.mapper.CrmCompanyPurseMapper;
import com.tancire.net.domain.CrmCompanyPurse;
import com.tancire.net.service.ICrmCompanyPurseService;

/**
 * 客户收益Service业务层处理
 *
 * @author chenchao
 * @date 2023-12-30
 */
@Service
public class CrmCompanyPurseServiceImpl implements ICrmCompanyPurseService {
    @Resource
    private CrmCompanyPurseMapper crmCompanyPurseMapper;

    /**
     * 查询客户收益
     *
     * @param id 客户收益主键
     * @return 客户收益
     */
    @Override
    public CrmCompanyPurse selectCrmCompanyPurseById(Long id) {
        return crmCompanyPurseMapper.selectCrmCompanyPurseById(id);
    }

    /**
     * 查询客户收益列表
     *
     * @param crmCompanyPurse 客户收益
     * @return 客户收益
     */
    @Override
    public List<CrmCompanyPurse> selectCrmCompanyPurseList(CrmCompanyPurse crmCompanyPurse) {
        return crmCompanyPurseMapper.selectCrmCompanyPurseList(crmCompanyPurse);
    }

    /**
     * 新增客户收益
     *
     * @param crmCompanyPurse 客户收益
     * @return 结果
     */
    @Override
    public int insertCrmCompanyPurse(CrmCompanyPurse crmCompanyPurse) {
        crmCompanyPurse.setCreateTime(DateUtils.getNowDate());
        return crmCompanyPurseMapper.insertCrmCompanyPurse(crmCompanyPurse);
    }

    /**
     * 修改客户收益
     *
     * @param crmCompanyPurse 客户收益
     * @return 结果
     */
    @Override
    public int updateCrmCompanyPurse(CrmCompanyPurse crmCompanyPurse) {
        crmCompanyPurse.setUpdateTime(DateUtils.getNowDate());
        return crmCompanyPurseMapper.updateCrmCompanyPurse(crmCompanyPurse);
    }

    /**
     * 批量删除客户收益
     *
     * @param ids 需要删除的客户收益主键
     * @return 结果
     */
    @Override
    public int deleteCrmCompanyPurseByIds(Long[] ids) {
        return crmCompanyPurseMapper.deleteCrmCompanyPurseByIds(ids);
    }

    /**
     * 删除客户收益信息
     *
     * @param id 客户收益主键
     * @return 结果
     */
    @Override
    public int deleteCrmCompanyPurseById(Long id) {
        return crmCompanyPurseMapper.deleteCrmCompanyPurseById(id);
    }

    /**
     * 根据企业账号ID，查询汇总收益数据
     *
     * @param userId
     * @return
     */
    @Override
    public CrmCompanyPurse selectCrmCompanyPurseByCompanyId(Long userId) {
        return crmCompanyPurseMapper.selectCrmCompanyPurseByCompanyId(userId);
    }

    /**
     * 更新钱包可提现金额
     *
     * @param crmCompanyPurse
     */
    @Override
    public void updateWithdrawPrice(CrmCompanyPurse crmCompanyPurse) {
        this.crmCompanyPurseMapper.updateWithdrawPrice(crmCompanyPurse);
    }
}
